package com.gongren.project.job.pay;

import com.alibaba.dubbo.config.annotation.Reference;
import com.gongren.project.pay.rpc.api.taskRpc.ICmbPublicKeyTaskRpcService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @Author houzhong
 * @Date 2017/9/4 9:21
 */
@Component("cmbPublicKeyTask")
public class CmbPublicKeyTask {

    private static Logger Logger = LoggerFactory.getLogger(CmbPublicKeyTask.class);

    @Reference
    private ICmbPublicKeyTaskRpcService cmbPublicKeyTaskRpcService;

    @PostConstruct
    public void initPublicKey(){
        getCmbPublicKeyTask();
    }

    /**
     * 定时 每天早上 2:15分获取 招行公钥
     */
    //@Scheduled(cron = "0 15 2 ? * *")
    public void getCmbPublicKeyTask(){

        Logger.info("CmbPublicKeyTask and getCmbPublicKeyTask start");
        try {
            cmbPublicKeyTaskRpcService.findAllGetCmbPublicKeyTask();
            Logger.info("CmbPublicKeyTask and getCmbPublicKeyTask end");
        }catch (Exception e) {
            Logger.error("CmbPublicKeyTask and getCmbPublicKeyTask :" , e);
        }
    }
}
